def wordPattern(self, pattern, s):
    words = s.split()
    if len(words)!= len(pattern):
        return False
    map={}
    for i in range(len(words)):
      key=words[i]
      value=map.get(key)
      if key not in map:
        if map.values().count(pattern[i])!=0:
          return False
        else:
          map[key]=pattern[i]
      else:
        if value!=pattern[i]:
          return False
    return True